/*
* Author: Sowmya Kameswaran
*/
package com.foo.SnapshotData;

import java.sql.Date;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;


public class SnapshotDataClient 
{
	SnapshotDataProviderRemote dataprovider = null;
	public SnapshotDataClient()
	{
		try
		{
			Properties properties = new Properties();
			properties.put(Context.PROVIDER_URL, "jnp://localhost:1099");
			properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
			properties.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
			Context ctx = new InitialContext(properties);
			Object ref = ctx.lookup("SnapshotDataProvider/remote");
			//DataProviderRemote 
			dataprovider = (SnapshotDataProviderRemote) PortableRemoteObject.narrow(ref, SnapshotDataProviderRemote.class);

		}
		catch(Exception e)
		{
			e.printStackTrace();
		}	
	}
	
	public void sendsnapshotinfo(String sorttype,String paramname,Date fromdate,Date todate)
	{
		dataprovider.sendsnapshotinfo(sorttype, paramname, fromdate, todate);
		System.out.println("Sending data to server");
	}
}
